package com.heima.admin.controller.v1;

import com.heima.admin.service.UserLoginService;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 胡慧
 * @title: LoginController
 * @projectName heima-leadnews
 * @description: 登录
 * @date 2021/2/518:02
 */
@RestController
@Slf4j
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private UserLoginService userLoginService;

    @ApiOperation("用户登录")
    @PostMapping("/in")
    public ResponseResult login(@RequestBody AdUserDto dto) {
        return userLoginService.login(dto);
    }

   @ApiOperation("用户注册")
   @PostMapping("/register")
    public ResponseResult register(@RequestBody AdUser adUser){
        return userLoginService.register(adUser);
   }
}
